<?php


namespace App\Models;


use App\Engine\BaseModel;
use App\Engine\TokenService;
use App\Exceptions\ApiException;

class Order extends BaseModel
{
    protected $table = 'orders';
    protected $fillable = [
        'order_num',
        'uid',
        'pay_state',
        'state',
        'pay_time'
    ];

    public $rule=[
        "price"=>"required"
    ];

    public $ruleMessage=[
        "price.required"
    ];

    public function check_phone()
    {
        $user=User::where("id",TokenService::getCurrentUid())->first();
       /* if (!$user["phone"]){
            throw new ApiException("请先绑定号码");
        }*/
        return $user;
    }

    public function getPayTimeAttribute($value)
    {
        return $value==""?$value:date("Y-m-d H:i:s",$value);
    }

}
